{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from PIL import Image\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 导入语句说明\n",
    "\n",
    "* 语句：import  A as B    \n",
    "* 功能：导入模块A，运行时呼唤其昵称B代表A\n",
    "* 非恰当例如： import 苏炳添 as 小苏\n",
    "* 补充：执行该模块功能时用“.”\n",
    "* 如：用“小苏.跑100米”以亚洲速度奔跑\n",
    "\n",
    "* 语句：from A import B   \n",
    "* 功能： 从某包A中导入某模块B\n",
    "* 非恰当例如： from 交中初级 import 人工智能社团\n",
    "\n",
    "* 语句：import A.B as C   \n",
    "* 功能： 将某库中某功能导入，用昵称C代表\n",
    "* 非恰当例如： import 冯老师.唱歌 as 神灯\n",
    "* 使用情境：当你参加团建活动时，执行“神灯”，于是冯老师帮你唱首歌"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 作用\n",
    "* 当调用matplotlib.pyplot的绘图函数plot()进行绘图的时候，直接生成图像。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "a=np.zeros([10,10], dtype = np.uint8)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 作用\n",
    "* 将10*10的矩阵赋值给a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
       "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
       "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
       "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
       "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
       "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
       "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
       "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
       "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
       "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 作用\n",
    "* 在jupyter notebook中最后一个不带赋值号的变量，等效于打印语句print（a）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  0,   0,   0, 100,   0,   0,   0,   0,   0,   0],\n",
       "       [  0,   0,   0, 255, 255,   0,   0,   0,   0,   0],\n",
       "       [  0,   0, 255,   0,   0, 255,   0,   0,   0,   0],\n",
       "       [  0, 255,   0,   0,  20, 255,   0,   0,   0,   0],\n",
       "       [255,   0,   0,   0, 250,   0,   0,   0,   0,   0],\n",
       "       [  0,   0,   0,   0, 250,   0,   0,   0,   0,   0],\n",
       "       [  0,   0,   0, 255,   0,   0,   0,   0,   0,   0],\n",
       "       [  0,   0,   0, 255,   0,   0,   0,   0,   0,   0],\n",
       "       [  0,   0,   0, 255,   0,   0,   0,   0,   0,   0],\n",
       "       [  0,   0,   0, 255, 250, 255, 255, 255,   0,   0]], dtype=uint8)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b=np.array([[0, 0, 0, 100, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 255, 255, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 255, 0, 0, 255, 0, 0, 0, 0],\n",
    "       [0, 255, 0, 0, 20, 255, 0, 0, 0, 0],\n",
    "       [255, 0, 0, 0, 250, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 250, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 255, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 255, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 255, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0,255, 250,255, 255, 255, 0, 0]], dtype=np.uint8)\n",
    "b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 操作\n",
    "* 复制上一个cell运行的结果，并改动部分0为255.\n",
    "***\n",
    "\n",
    "## 观察\n",
    "* 输出后可观察到2的轮廓。\n",
    "***\n",
    "\n",
    "## 建议\n",
    "* 仿照改动一些数值，呈现数字1。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "im = Image.fromarray(np.uint8(b))\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#构造图片\n",
    "#转换数值格式为np.uint8"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "im.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 发现问题\n",
    "* 直接显示，非常小"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x1b8e685b898>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPgAAAD8CAYAAABaQGkdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHR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slC2fmvkW8Cpqvra3PMsU1V3VdWhqjrM1uv606ralVuZqnoeeCbJe7afug54fMaRlnkauCbJ/u33xXXs4g8FYbrfJluoql5O8gXgQbY+ifx2VZ2cY5YBrgU+BzyW5Ffbz91dVQ/MOFMnXwS+v/0f/ZPArTPPc05V9XCS48AJtr5deZRdflabZ7JJjXkmm9SYgUuNGbjUmIFLjRm41JiBS40ZuNSYgUuN/ROVB3e07r12LQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.imshow(im)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 作用\n",
    "* 在jupyter中显示图片，会放大看得更清楚，前面%matplotlib inline在这里有用，否则显示不出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "im.save(\"2.jpeg\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 作用\n",
    "* 保存图片\n",
    "#plt.savefig(\"1.jpeg\")  ？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "im = Image.open(\"2.jpeg\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 作用\n",
    "* 打开并读取图片2.JPEG，将读取到的数据赋值给im"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "matrix = np.asarray(im) "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 作用\n",
    "* 将im中的数据拷贝到matrix\n",
    "***\n",
    "## 区别\n",
    "* im是图片，matrix是图片对应的数据。\n",
    "***\n",
    "# 本课重点\n",
    "* 计算机把im理解为matrix，把各种声、图、酸碱度等都作为数据理解。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[  0,   5,   0, 102,   1,   0,   8,   1,   0,   0],\n",
       "       [  0,   2,   5, 255, 252,   7,   0,   3,   0,   0],\n",
       "       [  8,   0, 255,   0,  13, 250,   5,   0,   0,   0],\n",
       "       [  0, 255,   1,   7,   5, 255,   3,   4,   0,   0],\n",
       "       [255,   0,   0,  16, 255,   2,   0,   9,   0,   0],\n",
       "       [  0,  30,   0,   0, 255,   8,   0,   4,   0,   0],\n",
       "       [ 11,   0,  13, 254,   0,  10,   0,   5,   0,   0],\n",
       "       [  1,   0,   0, 255,   6,   0,   3,   0,   0,   0],\n",
       "       [  2,   6,   0, 241,  12,   6,   0,   0,   0,   0],\n",
       "       [  0,   0,  11, 255, 234, 247, 255, 255,   0,   0]], dtype=uint8)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "matrix"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 总结\n",
    "* 图片就是一个矩阵\n",
    "## 练习\n",
    "* 请构造出0，1，2，3，4，5，6，7，8，9这十个数的图片\n",
    "## 发现问题\n",
    "* 全是黑色，如何呈现彩色呢？\n",
    "* 人眼所看到的各种颜色，都是红绿蓝的不同比例组合，因此同一个点若获得三种颜色的参数，可以呈现出彩色。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "red=np.array([[255, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [255, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [255, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [255, 0, 0, 0, 20, 0, 0, 0, 0, 0],\n",
    "       [255, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [255, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "green=np.array([[0, 0, 0, 100, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 255, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 200, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 20, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 250, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 250, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 250, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 250, 0, 0, 0, 0, 0]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "blue=np.array([[0, 0, 0, 100, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 255, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 200, 0, 0, 200, 0, 0],\n",
    "       [0, 0, 0, 0, 20, 0, 0, 255, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 255, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 255, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n",
    "       [0, 0, 0, 0, 0, 0, 0, 255, 0, 0]])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 作用\n",
    "* 对应b矩阵，分别设置红绿蓝三个数据参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPgAAAD8CAYAAABaQGkdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAACg9JREFUeJzt3cGrXOUdxvHnaWLQxEqFCMUkNBHENght5CLR0FKMC62iLrpQ0IWbbGqNYpG0f4OILkQIUTeKLmIWIqIW6qYLgzeJReNVCNFqNGICrYqbGHy6uFNIbTJzkntez8wv3w8IuTcnb365zNf3zMyZGScRgJp+NPQAANohcKAwAgcKI3CgMAIHCiNwoDACBwojcKAwAgcKW95i0dV21jdYd1+DNZtZvbrNusePt1kXMyeJJx3TJPD1kuYbrDvxXzNN7rijzbq7drVZFyVxig4URuBAYQQOFEbgQGEEDhRG4EBhnQK3fZPtD2wfsr2j9VAA+jExcNvLJD0h6WZJGyXdZXtj68EALF2XHfxaSYeSHE5yQtILkm5vOxaAPnQJfI2kT075+sjoe//D9jbb87bnj/U1HYAl6RL46a4Q/b+3Yk2yM8lckrnLlj4XgB50CfyIpHWnfL1W0mdtxgHQpy6BvyXpStsbbK+QdKekl9qOBaAPE19NluSk7fskvSZpmaSnkxxsPhmAJev0ctEkr0h6pfEsAHrGlWxAYQQOFEbgQGEEDhRG4EBhbvH54HN2zvs3XWyl1ee5m5/urOnyrqrs4EBhBA4URuBAYQQOFEbgQGEEDhRG4EBhBA4URuBAYQQOFEbgQGEEDhRG4EBhBA4URuBAYQQOFEbgQGEEDhRG4EBhBA4URuBAYZ0+mwxTZO/eoSeYEm82WHNzgzWHxQ4OFEbgQGEEDhRG4EBhBA4URuBAYRMDt73O9hu2F2wftL39hxgMwNJ1eR78pKSHkuy3/WNJ+2z/Ncl7jWcDsEQTd/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V0EOdSZJPJT0i6WNJRyV9meT1Yacab6jAT3ed4VQ/nG/7YkkvSnogyVdDz3Mmtm+V9EWSfUPP0sFySddIejLJJknfSJrmx2Mu1eKZ5gZJl0taZfvuYacab6jAj0had8rXazXFpzq2L9Bi3M8l2TP0PBNskXSb7Y+0eNfnBtvPDjvSGR2RdCTJf8+Idmsx+Gl1o6QPkxxL8q2kPZKuH3imsYYK/C1JV9reYHuFFh+oeGmgWcaybS3eR1xI8ujQ80yS5M9J1iZZr8Wf69+STOUuk+RzSZ/Yvmr0ra2S3htwpEk+lrTZ9srR7WKrpvhBQandq8nGSnLS9n2SXtPiI5FPJzk4xCwdbJF0j6R3bL89+t5fkrwy4EyV/FHSc6P/0R+WdO/A85xRkr22d0var8VnVw5oyq9q40o2oDCuZAMKI3CgMAIHCiNwoDACBwojcKAwAgcKI3CgsP8ADG84gTZ5YPUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "c=np.array([red,green,blue])\n",
    "# c=c.swapaxes(2,0).swapaxes(1,0)\n",
    "c=c.transpose(1,2,0)\n",
    "im = Image.fromarray(np.uint8(c))\n",
    "plt.imshow(im)\n",
    "im.save(\"caise.jpeg\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 练习\n",
    "* 修改上面红绿蓝参数，设置不同点的信息，观察对应的颜色变化。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on function swapaxes in module numpy.core.fromnumeric:\n",
      "\n",
      "swapaxes(a, axis1, axis2)\n",
      "    Interchange two axes of an array.\n",
      "    \n",
      "    Parameters\n",
      "    ----------\n",
      "    a : array_like\n",
      "        Input array.\n",
      "    axis1 : int\n",
      "        First axis.\n",
      "    axis2 : int\n",
      "        Second axis.\n",
      "    \n",
      "    Returns\n",
      "    -------\n",
      "    a_swapped : ndarray\n",
      "        For NumPy >= 1.10.0, if `a` is an ndarray, then a view of `a` is\n",
      "        returned; otherwise a new array is created. For earlier NumPy\n",
      "        versions a view of `a` is returned only if the order of the\n",
      "        axes is changed, otherwise the input array is returned.\n",
      "    \n",
      "    Examples\n",
      "    --------\n",
      "    >>> x = np.array([[1,2,3]])\n",
      "    >>> np.swapaxes(x,0,1)\n",
      "    array([[1],\n",
      "           [2],\n",
      "           [3]])\n",
      "    \n",
      "    >>> x = np.array([[[0,1],[2,3]],[[4,5],[6,7]]])\n",
      "    >>> x\n",
      "    array([[[0, 1],\n",
      "            [2, 3]],\n",
      "           [[4, 5],\n",
      "            [6, 7]]])\n",
      "    \n",
      "    >>> np.swapaxes(x,0,2)\n",
      "    array([[[0, 4],\n",
      "            [2, 6]],\n",
      "           [[1, 5],\n",
      "            [3, 7]]])\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(np.swapaxes)\n",
    "# help(c.swapaxes)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 作用\n",
    "* 要查看一个库或函数的用法，可以用help（）函数查看帮助"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
